package minStream;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class StreamMinExample {
    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, -1, 6, 7);

        // Using Stream.min() to find the minimum value in the list
        Optional<Integer> minNumber = numbers.stream()
                .min(Integer::compare);

        // Checking and displaying the minimum number
        if (minNumber.isPresent()) {
            System.out.println("The minimum number is " + minNumber.get());
        } else {
            System.out.println("List is empty.");
        }
    }
}
